import * as service from "@/service";
import { ITicket } from "./interface";
const ticket: ITicket = {
  state: {
    ticketList: [],
    ticketTabs: [],
  },
  actions: {
    async getTicketList({ commit }, { categoryId }) {
      const res = await service.fetchTicketList(categoryId);
      commit({
        type: "GET_TICKET_LIST",
        payload: res?.data?.lists,
      });
    },
    async getTicketTabs({ commit }) {
      const res = await service.fetchTicketTabs();
      const res2 = await service.fetchTicketList("");
      commit({
        type: "GET_TICKET_TABS",
        payload: res?.data?.categoryRespVOS,
        list: res2?.data?.lists,
      });
    },
  },
  mutations: {
    GET_TICKET_LIST(state, { payload }) {
      state.ticketList = payload;
    },
    GET_TICKET_TABS(state, { payload, list }) {
      state.ticketTabs = payload;
      state.ticketList = list;
    },
  },
  namespaced: true,
};
export default ticket;
